package Model;

public class GateImpl implements Gate {

	private State state;
	public GateImpl(State state) {
		this.state = state;
	}
	
	@Override
	public void open() {
		if(state.equals(State.OPEN))
			throw new IllegalStateException("Gate already open.");
		state = State.OPEN;
	}

	@Override
	public void close() {
		if(state.equals((State.CLOSED))
			throw new IllegalStateException("Gate already closed.");
		state = State.CLOSED;
	}
	
	@Override
	public State getState() {
		return state;
	}

}
